<template>
    <div class="box">
        <el-button type="primary" size="small" @click="$router.go(-1)">
            返回列表
        </el-button>
        <!--    <h2>审核详情</h2>-->
        <!--<router-view></router-view>-->
        <component :is="moduleItem"></component>
        <div class="make" v-if="$route.query.type==4">
            <div>
                <el-button type="primary" size="small" @click="feedback(1)">
                    通过
                </el-button>
                <el-button type="primary" size="small"  @click="feedback(0)">
                    不通过
                </el-button>
            </div>
            <div class="reject_msg">
                <el-input
                        type="textarea"
                        :rows="4"
                        placeholder="请输入驳回理由"
                        v-model="reject_msg">
                </el-input>

            </div>
        </div>
        <!--    <div class="list">-->
        <!--      <el-tabs type="border-card">-->
        <!--        <el-table class="table" :data="tableData" style="width: 100%">-->
        <!--          <el-table-column-->
        <!--            prop="idx"-->
        <!--            label="序号"-->
        <!--            width="180"-->
        <!--          ></el-table-column>-->
        <!--          <el-table-column-->
        <!--            prop="dan_number"-->
        <!--            label="单号"-->
        <!--            width="180"-->
        <!--          ></el-table-column>-->
        <!--          <el-table-column-->
        <!--            prop="name"-->
        <!--            label="申请人姓名"-->
        <!--            width="180"-->
        <!--          ></el-table-column>-->
        <!--          <el-table-column-->
        <!--            prop="phone"-->
        <!--            label="电话号码"-->
        <!--            width="180"-->
        <!--          ></el-table-column>-->
        <!--          <el-table-column-->
        <!--            prop="business_type"-->
        <!--            label="业务类别"-->
        <!--            width="280"-->
        <!--            align="center"-->
        <!--          ></el-table-column>-->

        <!--          <el-table-column prop="operate" label="操作" align="center">-->
        <!--            <template slot-scope="scope">-->
        <!--              <el-button type="primary" size="small" @click="details(scope.row)"-->
        <!--                >查看详情</el-button-->
        <!--              >-->
        <!--            </template>-->
        <!--          </el-table-column>-->
        <!--        </el-table>-->
        <!--        <div class="paging">-->
        <!--          <el-pagination-->
        <!--            background-->
        <!--            @size-change="handleSizeChange"-->
        <!--            @current-change="handleCurrentChange"-->
        <!--            :current-page="pageSize"-->
        <!--            :page-size="pageNum"-->
        <!--            layout="prev, pager,next"-->
        <!--            :total="total"-->
        <!--          ></el-pagination>-->
        <!--        </div>-->
        <!--      </el-tabs>-->
        <!--    </div>-->
    </div>
</template>
<script>
    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    //当组件在被加载的时候对其进行判断，选择需要引入的表单
    var BashStep3 = (resolve) => {
        //  let a = location.search.substring(4);
        let url = GetRequest();
        return require([`../detailPage/businessForm${url["class_id"]}`], resolve);
    };
    export default {
        data() {
            return {
                // // 当前页
                // pageSize: 1,
                // // 每页数据
                // pageNum: 10,
                // total: "",
                // url: "",
                // upUrl: "",
                // tableData: [],
                reject_msg: "",
                moduleItem:BashStep3,
                show_child: true, //当时修改时,等待异步完成
            };
        },
        components: {
            BashStep3,
        },
        methods: {
            // details(item) {
            //   let contentData = {
            //     id: item.id,
            //     num: item.dan_number,
            //     classId: item.modelId,
            //   };
            //   this.$store.commit("setId", contentData);
            //   this.$router.push({
            //     path: "/content",
            //     // path: "",
            //     query: {
            //       url: item.url,
            //       upUrl: item.upUrl,
            //     },
            //   });
            // },
            feedback(type){
                let url="/trademark/proPublic/backSH"
                let formData=new FormData()
                formData.append("id",this.$route.query.id)
                if(!type){
                    //不通过
                    if(this.reject_msg.length<1){
                        this.$message({
                            type:"error",
                            message:"审核不通过时,必须填写不通过原因"
                        })
                        return
                    }
                    formData.append("content",this.reject_msg)
                    formData.append("type",3)
                }else{
                    formData.append("type",2)
                }
                this.$http({
                    url:url,
                    method:"post",
                    headers:{
                        "Content-type":"application/json"
                    },
                    data:formData
                }).then((res)=>{

                    if(res.data.code==200){
                        this.$message({
                            type:"success",
                            message:"操作成功"
                        })
                        this.$router.go(-1)
                    }else{
                        this.$message({
                            type:"error",
                            message:res.data.message
                        })
                    }
                })
            },
            handleSizeChange(val) {
                // //console.log(`每页 ${val} 条`);
                this.pageNum = val;
            },
            handleCurrentChange(val) {
                // //console.log(`当前页: ${val}`);
                this.pageSize = val;
            },
        },

        mounted() {
//            this.moduleItem=this.$route.query.class_id
            // let num = this.$route.query.dan_number;
            // this.$http.get(`/trademark/proPublic/getBus/${num}`).then((result) => {
            //   let data = result.data.data.list;
            //   this.total = result.data.data.total;
            //   data.forEach((item, index) => {
            //     this.tableData.push({
            //       idx: index,
            //       dan_number: item.certId,
            //       name: item.appName,
            //       phone: item.phone,
            //       business_type: item.name,
            //       id: item.id,
            //       url: item.findById,
            //       upUrl: item.updateById,
            //       modelId: item.modelId,
            //     });
            //   });
            // });
        },
        destroyed() {
            BashStep3 = (resolve) => {
                //                let a = location.search.substring(4);
                //                return require([`./BashStepForm${a}`], resolve);
                let url = GetRequest();
//                return () => import(`../detailPage/bashStepForm${url["class_id"]}`);
                return require([`../detailPage/businessForm${url["class_id"]}`], resolve);
            };
        },
    };
</script>
<style lang="less" scoped>
    .box {
        padding: 20px;
        > .el-button {
            display: block;
        }
        .tiao {
            color: #fff;
            text-decoration: none;
        }
        h2 {
            margin: 20px;
            font-size: 20px;
            text-align: left;
        }
        .paging {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }
    }

</style>
<style>
    .make{
        margin-left: 60px;
    }
    .reject_msg {
        margin-top: 30px;
        width: 600px;
        margin-bottom: 60px;
    }
</style>
